package com.gxar.quick.ar.server.base.controller;

import cn.hutool.core.bean.BeanUtil;
import com.gxar.common.entity.Result;
import com.gxar.quick.ar.server.base.facade.ShareFacade;
import com.gxar.quick.ar.server.base.model.exchange.vo.request.AdminExchangeItemPreviewRequest;
import com.gxar.quick.ar.server.base.model.exchange.vo.response.AdminExchangeItemPreviewResponse;
import com.gxar.quick.ar.server.base.model.share.vo.request.AdminUnlimitedQRCodeRequest;
import com.gxar.quick.ar.server.base.model.share.vo.request.UnlimitedQRCodeRequest;
import com.gxar.quick.ar.server.base.model.share.vo.response.AdminUnlimitedQRCodeResponse;
import com.gxar.quick.ar.server.base.model.share.vo.response.UnlimitedQRCodeResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author linsy
 * @version 1.0
 * @created 2024/3/13 16:14
 */
@Api(tags = "管理端工具接口")
@RestController
@RequestMapping("/admin/api/utils")
@RequiredArgsConstructor
@Slf4j
public class AdminUtilsController {

    private final ShareFacade shareFacade;

    @ApiOperation("生成微信二维码")
    @PostMapping("/wechat/unlimitedQRCode")
    public Result<AdminUnlimitedQRCodeResponse> preview(@RequestBody AdminUnlimitedQRCodeRequest request) {
        UnlimitedQRCodeRequest unlimitedQRCodeRequest = new UnlimitedQRCodeRequest();
        BeanUtil.copyProperties(request, unlimitedQRCodeRequest);
        UnlimitedQRCodeResponse result = shareFacade.getUnlimitedQRCode(unlimitedQRCodeRequest);
        AdminUnlimitedQRCodeResponse response = new AdminUnlimitedQRCodeResponse();
        response.setBuffer(result.getBuffer());
        return Result.success(response);
    }

}
